/*
 * @Author: szx
 * @Date: 2021-10-10 17:03:20
 * @LastEditTime: 2021-10-10 18:55:48
 * @Description:
 * @FilePath: \leetcode\441\441.go
 */

package main

import (
	"fmt"
	"sort"
)

func arrangeCoins(n int) int {
	// return int((math.Sqrt(float64(8*n+1)) - 1) / 2)
	return sort.Search(n, func(k int) bool { k++; fmt.Println(k); return k*(k+1) > 2*n })
	// if n == 1 {
	// 	return 1
	// }
	// return sort.Search(n, func(k int) bool { fmt.Println(k); return k*(k+1) > 2*n }) - 1

}

func main() {
	fmt.Println(arrangeCoins(8))

}
